Next: Transaction Queues, Previous: Query Before Exit, Up: Processes [Contents][Index]
In addition to accessing and manipulating processes that are subprocesses of the current Emacs session, Emacs Lisp programs can also access other processes running on the same machine. We call these system processes, to distinguish them from Emacs subprocesses.
Emacs provides several primitives for accessing system
processes. Not all platforms support these primitives; on those
which don’t, these primitives return nil.
This function returns a list of all the processes running on the system. Each process is identified by its PID, a numerical process ID that is assigned by the OS and distinguishes the process from all the other processes running on the same machine at the same time.
This function returns an alist of attributes for the
process specified by its process ID pid. Each
association in the alist is of the form (key
. value), where key designates
the attribute and value is the value of that
attribute. The various attribute keys that this
function can return are listed below. Not all platforms
support all of these attributes; if an attribute is not
supported, its association will not appear in the returned
alist. Values that are numbers can be either integer or
floating point, depending on the magnitude of the value.
euidThe effective user ID of the user who invoked the
process. The corresponding value is a number.
If the process was invoked by the same user who runs the
current Emacs session, the value is identical to what
user-uid returns (see User
Identification).
userUser name corresponding to the process’s effective user ID, a string.
egidThe group ID of the effective user ID, a number.
groupGroup name corresponding to the effective user’s group ID, a string.
commThe name of the command that runs in the process. This is a string that usually specifies the name of the executable file of the process, without the leading directories. However, some special system processes can report strings that do not correspond to an executable file of a program.
stateThe state code of the process. This is a short string that encodes the scheduling state of the process. Here’s a list of the most frequently seen codes:
"D"uninterruptible sleep (usually I/O)
"R"running
"S"interruptible sleep (waiting for some event)
"T"stopped, e.g., by a job control signal
"Z"zombie: a process that terminated, but was not reaped by its parent
For the full list of the possible states, see the
manual page of the ps command.
ppidThe process ID of the parent process, a number.
pgrpThe process group ID of the process, a number.
sessThe session ID of the process. This is a number that is the process ID of the process’s session leader.
ttnameA string that is the name of the process’s controlling terminal. On Unix and GNU systems, this is normally the file name of the corresponding terminal device, such as /dev/pts65.
tpgidThe numerical process group ID of the foreground process group that uses the process’s terminal.
minfltThe number of minor page faults caused by the process since its beginning. (Minor page faults are those that don’t involve reading from disk.)
majfltThe number of major page faults caused by the process since its beginning. (Major page faults require a disk to be read, and are thus more expensive than minor page faults.)
cminfltcmajfltLike minflt and majflt, but
include the number of page faults for all the child
processes of the given process.
utimeTime spent by the process in the user context, for
running the application’s code. The corresponding
value is in the
(high low microsec picosec)
format, the same format used by functions
current-time (see current-time) and
file-attributes (see File
Attributes).
stimeTime spent by the process in the system (kernel)
context, for processing system calls. The corresponding
value is in the same format as for
utime.
timeThe sum of utime and stime.
The corresponding value is in the same format
as for utime.
cutimecstimectimeLike utime, stime, and
time, but include the times of all the child
processes of the given process.
priThe numerical priority of the process.
niceThe nice value of the process, a number. (Processes with smaller nice values get scheduled more favorably.)
thcountThe number of threads in the process.
startThe time when the process was started, in the same
(high low microsec
picosec) format used by
file-attributes and
current-time.
etimeThe time elapsed since the process started, in the
format (high low
microsec picosec).
vsizeThe virtual memory size of the process, measured in kilobytes.
rssThe size of the process’s resident set, the number of kilobytes occupied by the process in the machine’s physical memory.
pcpuThe percentage of the CPU time used by the process since it started. The corresponding value is a floating-point number between 0 and 100.
pmemThe percentage of the total physical memory installed on the machine used by the process’s resident set. The value is a floating-point number between 0 and 100.
argsThe command-line with which the process was invoked.
This is a string in which individual command-line
arguments are separated by blanks; whitespace characters
that are embedded in the arguments are quoted as
appropriate for the system’s shell: escaped by
backslash characters on GNU and Unix, and enclosed in
double quote characters on Windows. Thus, this
command-line string can be directly used in primitives
such as shell-command.
Next: Transaction Queues, Previous: Query Before Exit, Up: Processes [Contents][Index]